package com.sinosoft.flow.service.impl;

import com.sinosoft.flow.dao.UserMapper;
import com.sinosoft.flow.domain.po.SystemUser;
import com.sinosoft.flow.domain.vo.UserLoginVO;
import com.sinosoft.flow.service.UserService;
import com.sinosoft.flow.token.generator.JwtTokenGenerator;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: tangyongbo
 * @Description:
 * @Date: create in 2021/11/4 17:36
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private JwtTokenGenerator jwtTokenGenerator;

    @Override
    public List<SystemUser> selectUsers() {
        return userMapper.selectUsers();
    }

    @Override
    public String login(UserLoginVO userLoginVO) {
        SystemUser user=new SystemUser();
        BeanUtils.copyProperties(userLoginVO,user);
        return jwtTokenGenerator.createToke(user);
    }

}
